package com.haisen.dataobject.mapper.base;

import com.haisen.core.utils.MyMapper;
import com.haisen.dataobject.entity.ItemParamGroup;
import org.apache.ibatis.annotations.*;

import java.util.List;


public interface ItemParamGroupMapper extends MyMapper<ItemParamGroup> {



    /**
     * 根据groupId查所有的参数
     */

    @Select("select id,group_name as 'groupName' ,item_cat_id as 'itemCatId',item_cat_name as 'itemCatName'  from tb_item_param_group where id=#{0} ")
    @Results({
            @Result(property="itemKeyList",javaType=List.class,column="id",many=@Many(select="com.haisen.dataobject.mapper.base.ItemParamKeyMapper.selectByGroupId"))
    })
 /*   @Select(" select a.id,a.group_name as 'groupName',a.id as 'paramKeyId',b.param_name as 'paramName' from tb_item_param_group a,tb_item_param_key b where a.id=#{0} and a.id=b.group_id")*/
    ItemParamGroup selectGroupAndKey(Long id);


  /*  @Select("select id,group_name as 'groupName' ,item_cat_id as 'itemCatId',item_cat_name as 'itemCatName'  from tb_item_param_group where id in (#{0})" )*/

//增加了@Param参数注解
/*  @Select("select id,group_name as 'groupName' ,item_cat_id as 'itemCatId',item_cat_name as 'itemCatName'  from tb_item_param_group where id in (${ids})" )*/
//传入的是一个数组
 @Select("<script>"
          +"select id,group_name as 'groupName' ,item_cat_id as 'itemCatId',item_cat_name as 'itemCatName'  from tb_item_param_group where id in "
          +"<foreach item='item' index='index' collection='groupIds'      open='(' separator=',' close=')'>"
          + "#{item}"
          + "</foreach>"
          +"</script>")
    List<ItemParamGroup> selectGroupByCatId(@Param("groupIds") List<Long> groupIds);

}